/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CadastroEspecialidadePanel.java
 *
 * Created on Dec 1, 2010, 4:04:26 PM
 */

package clinicapoo.view.especialidade;

import clinicapoo.factory.Services;
import clinicapoo.model.Especialidade;
import clinicapoo.view.dialog.Dialogs;

import static clinicapoo.message.MessageResources.msg;

/**
 *
 * @author Fabio Montezuma
 */
public class CadastroEspecialidadePanel extends javax.swing.JInternalFrame {

    /** Creates new form CadastroEspecialidadePanel */
    public CadastroEspecialidadePanel() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        txtNome = new javax.swing.JTextField();
        btnCadastrar = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("resources/messages"); // NOI18N
        setTitle(bundle.getString("view.especialidade.cadastro.title")); // NOI18N
        setName("Form"); // NOI18N

        jLabel1.setText(bundle.getString("view.especialidade.cadastro.nome")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        txtNome.setName("txtNome"); // NOI18N

        btnCadastrar.setText(bundle.getString("view.especialidade.cadastro.btnCadastrar")); // NOI18N
        btnCadastrar.setName("btnCadastrar"); // NOI18N
        btnCadastrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCadastrarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnCadastrar)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtNome, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(18, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addComponent(btnCadastrar)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

	private void btnCadastrarActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnCadastrarActionPerformed
	{//GEN-HEADEREND:event_btnCadastrarActionPerformed
		try
		{
			Especialidade esp = new Especialidade();
			esp.setNome(txtNome.getText());

			Services.especialidade.cadastrar(esp);
			Dialogs.showInfo(this, msg("view.especialidade.cadastrar.sucesso"));
		}
		catch (Exception e)
		{
			Dialogs.showError(this, e);
		}
	}//GEN-LAST:event_btnCadastrarActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCadastrar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField txtNome;
    // End of variables declaration//GEN-END:variables

}
